Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  properties: {
    value: { //按钮名称
      type: String,
      value: '按钮'
    },
    bgColor: { //按钮颜色
      type: String,
      value: '#3565ee'
    },
    color: { //按钮文字颜色
      type: String,
      value: '#000'
    },
    radius: { //圆角尺寸
      type: [Number, String],
      value: 5
    },
    type: { //按钮类型 default默认 grad渐变色 primary主色 warn警告
      type: String,
      value: 'default'
    },
    grad: { //渐变色
      type: String,
      value: `linear-gradient(90deg, #5961ff, #47a1ff)`
    },
    size: { //按钮尺寸 default默认 mini小按钮
      type: String,
      value: 'default'
    },
    openType: { //微信开放能力
      type: String,
      value: ''
    },
    loading: { //名称前是否带 loading 图标
      type: Boolean,
      value: false
    },
    disabled: { //禁用按钮
      type: Boolean,
      value: false
    },
    hoverStopPropagation: { //指定是否阻止本节点的祖先节点出现点击态
      type: Boolean,
      value: false
    },
    url: { //跳转链接,openType为空时有效
      type: String,
      value: ''
    },
    navigateTo: { //跳转方式
      type: String,
      value: ''
    }
  },
  data: {
    
  },
  methods: {
    handlegetuserinfo(e){
      this.triggerEvent('getuserinfo',e.detail);
    },
    handlegetphonenumber(e){
      this.triggerEvent('getphonenumber',e.detail);
    },
    handleerror(e){
      this.triggerEvent('error',e.detail);
    },
    handleopensetting(e){
      this.triggerEvent('opensetting',e.detail);
    },
    handlelaunchapp(e){
      this.triggerEvent('launchapp',e.detail);
    },
    onClick() {
      if(this.data.openType) return;
      if (this.data.url) {
        switch (this.data.navigateTo) {
          case 'redirectTo':
            wx.redirectTo({
              url: this.data.url
            });
            break;
          case 'switchTab':
            wx.switchTab({
              url: this.data.url
            });
            break;
          case 'reLaunch':
            wx.reLaunch({
              url: this.data.url
            });
            break;
          default:
            wx.navigateTo({
              url: this.data.url
            });
        }
      } else {
        this.triggerEvent('click')
      }
    }
  }
})
